﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Clien_Default : System.Web.UI.Page
{
    Service.Service s;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["Student"] == null)
        {
            Response.Redirect("LoginStudent.aspx");
        }
        else
        {
            s = new Service.Service();
            string namestudent = Session["Student"].ToString();
            int CodeProfileStudent = s.SP_CodeProfileStudent(namestudent);
            Repeater1.DataSource = s.ListAdmission(CodeProfileStudent);
            Repeater1.DataBind();
        }

    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        if (Session["Student"] == null)
        {
            Response.Redirect("LoginStudent.aspx");
        }
        else
        {
            Response.Redirect("ListSubject.aspx");
        }

    }
    protected void LinkButton4_Click(object sender, EventArgs e)
    {
        if (Session["Student"] != null)
        {
            LinkButton btnYes = (LinkButton)sender;
            string NameSubjects = btnYes.CommandName;
            string namestudent = Session["Student"].ToString();
            int CodeProfileStudent = s.SP_CodeProfileStudent(namestudent);
            int CodeSubjects = s.CodeSubjects(NameSubjects);
            string status = s.StatusShow(CodeSubjects, CodeProfileStudent);
            if (status == "Yes")
            {
                Response.Redirect("Submit.aspx?NameSubjects=" + NameSubjects);
            }
            else
            {
                Response.Write("<script type='text/javascript' language='javascript'> alert('bạn chưa được phép vào học môn này')</script>");
            }

        }
        else
        {
            Response.Redirect("ListSubject.aspx");
        }

    }


}